package com.nuc.bigdata.config;

import com.nuc.bigdata.config.builder.MySwaggerBuilder;
import com.nuc.bigdata.config.director.Director;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author tianhao.luo
 * @date 2019/12/12 15:27
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket productApi() {
        // 建造者模式创建ApiInfo对象
        MySwaggerBuilder mySwaggerBuilder = new MySwaggerBuilder();
        Director director = new Director(mySwaggerBuilder);
        ApiInfo apiInfo = director.makeSwaggerApiInfo("图片资讯服务Swagger",
                "图片资讯服务API文档",
                "1.0 sna",
                "https://gitee.com/luotianhao25182/oa-bs",
                new Contact("tianhao.luo", "https://gitee.com/luotianhao25182", "768758693@qq.com"),
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0");
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.nuc.bigdata.controller"))
                .build().apiInfo(apiInfo).enable(true);
    }
}
